﻿<%@ Page Language="C#" MasterPageFile="~/MasterPages/AdminDefault.Master" AutoEventWireup="true"
  CodeBehind="AccountInfo.aspx.cs" Inherits="NguyenHoa.Web.Admin.AccountInfo" Title="" %>

<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxCallback" TagPrefix="dxcb" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377C8E3B72B4073"
  Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v9.1, Version=9.1.4.0, Culture=neutral, PublicKeyToken=5377c8e3b72b4073"
  Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
  <div>
    <table cellpadding="3" cellspacing="3" class="CommonFont">
      <tr style="padding-bottom: 10px;">
        <td>
          &nbsp;
        </td>
        <td colspan="4">
        </td>
      </tr>
      <tr>
        <td width="50px">
          &nbsp;
        </td>
        <td style="padding-bottom: 5px" width="100px">
          <asp:Label ID="Label2" runat="server" CssClass="CommonFont" Text="<%$Resources:Strings, Username %>"></asp:Label>
          :
        </td>
        <td width="150px" style="padding-bottom: 5px">
          <dxe:ASPxLabel ID="lblUsername" runat="server" Font-Bold="True" ClientInstanceName="lblUsername">
          </dxe:ASPxLabel>
        </td>
        <td width="50px">
        </td>
        <td>
          &nbsp;
        </td>
      </tr>
      <tr>
        <td>
          &nbsp;
        </td>
        <td style="padding-bottom: 5px">
          <asp:Label ID="Label5" runat="server" CssClass="CommonFont" Text="<%$Resources:Strings, FullName %>"></asp:Label>
          :
        </td>
        <td style="padding-bottom: 5px">
          <dxe:ASPxTextBox ID="txtFullName" runat="server" ClientEnabled="False" ClientInstanceName="txtFullName"
            Width="200px">
          </dxe:ASPxTextBox>
        </td>
        <td>
          &nbsp;
        </td>
        <td>
          &nbsp;
        </td>
      </tr>
      <tr>
        <td>
          &nbsp;
        </td>
        <td style="padding-bottom: 5px">
          <asp:Label ID="Label7" runat="server" CssClass="CommonFont" Text="<%$Resources:Strings, Email %>"></asp:Label>
          :
        </td>
        <td style="padding-bottom: 5px">
          <dxe:ASPxTextBox ID="txtEmail" runat="server" ClientEnabled="False" ClientInstanceName="txtEmail"
            Width="200px">
          </dxe:ASPxTextBox>
        </td>
        <td>
        </td>
        <td>
          &nbsp;
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td>
        </td>
        <td>
          <a onclick="onChangePassword()" style="text-decoration: underline">
            <%=GetGlobalResourceObject("Strings", "ChangePassword")%></a>
        </td>
        <td>
        </td>
        <td>
        </td>
      </tr>
      <tr>
        <td>
        </td>
        <td>
        </td>
        <td style="padding-top: 5px;">
          <div style="float: left;">
            <dxe:ASPxButton ID="btnEdit" runat="server" ClientInstanceName="btnEdit" Text="<%$ Resources:Strings, Edit %>"
              AutoPostBack="false">
              <ClientSideEvents Click="function(s, e) {onEdit();}" />
            </dxe:ASPxButton>
          </div>
          <div style="float: left; padding-left: 3px;">
            <dxe:ASPxButton ID="btnSave" runat="server" Text="<%$ Resources:Strings, Save %>"
              ClientInstanceName="btnSave" ClientEnabled="False" AutoPostBack="false">
              <ClientSideEvents Click="function(s, e) { onSave();}" />
            </dxe:ASPxButton>
          </div>
        </td>
        <td>
        </td>
        <td>
        </td>
      </tr>
    </table>
  </div>
  <div>
    <dxpc:ASPxPopupControl ID="pupAddEditDlg" runat="server" ClientInstanceName="pupAddEditDlg"
      HeaderText="<%$ Resources:Strings, ChangePassword %>" PopupHorizontalAlign="WindowCenter"
      PopupVerticalAlign="WindowCenter" AllowDragging="True" CloseAction="CloseButton"
      Modal="True">
      <ContentCollection>
        <dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
          <div>
            <table width="100%">
              <tr>
                <td>
                  <dxe:ASPxLabel ID="lblErrorMsg" runat="server" ClientInstanceName="lblErrorMsg" ForeColor="Red">
                  </dxe:ASPxLabel>
                </td>
              </tr>
              <tr>
                <td>
                  <table width="100%">
                    <tr>
                      <td width="130px">
                        <asp:Literal ID="Literal3" runat="server" Text="<%$ Resources:Strings, OldPassword %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxTextBox ID="txtOldPass" runat="server" ClientInstanceName="txtOldPass" Width="200px"
                          Password="True">
                        </dxe:ASPxTextBox>
                      </td>
                    </tr>
                    <tr>
                      <td>
                        <asp:Literal ID="Literal13" runat="server" Text="<%$ Resources:Strings, NewPassword %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxTextBox ID="txtNewPass" runat="server" ClientInstanceName="txtNewPass" Width="200px"
                          Password="True">
                        </dxe:ASPxTextBox>
                      </td>
                    </tr>
                    <tr>
                      <td>
                        <asp:Literal ID="Literal4" runat="server" Text="<%$ Resources:Strings, ConfirmPassword %>"></asp:Literal>
                        :
                      </td>
                      <td>
                        <dxe:ASPxTextBox ID="txtConfirmPass" runat="server" ClientInstanceName="txtConfirmPass"
                          Width="200px" Password="True">
                        </dxe:ASPxTextBox>
                      </td>
                    </tr>
                    <tr>
                      <td>
                      </td>
                      <td style="padding-top: 5px">
                        <div style="float: left;">
                          <dxe:ASPxButton ID="btnChangePass" runat="server" Text="<%$ Resources:Strings, Save %>"
                            AutoPostBack="false">
                            <ClientSideEvents Click="function(s, e) {changePassword();}" />
                          </dxe:ASPxButton>
                        </div>
                        <div style="float: left; padding-left: 3px;">
                          <dxe:ASPxButton ID="btnCancel" runat="server" Text="<%$ Resources:Strings, Cancel %>"
                            AutoPostBack="false">
                            <ClientSideEvents Click="function(s, e) {pupAddEditDlg.Hide();}" />
                          </dxe:ASPxButton>
                        </div>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
            </table>
          </div>
        </dxpc:PopupControlContentControl>
      </ContentCollection>
    </dxpc:ASPxPopupControl>
  </div>
  <dxcb:ASPxCallback ID="ctrCallback" ClientInstanceName="ctrCallback" runat="server"
    OnCallback="ctrCallback_Callback">
    <ClientSideEvents CallbackComplete="function(s, e) {onCallbackCompleted(s, e);}" />
  </dxcb:ASPxCallback>
  <asp:XmlDataSource ID="xdsRole" runat="server" XPath="Items/EmployeeRole/Role"></asp:XmlDataSource>

  <script type="text/javascript">
    function changePassword() {
      if (checkInput('PASS')) {
        ctrCallback.PerformCallback('ChangePassword');
      }
    }

    function onSave() {
      if (checkInput('INFO'))
        ctrCallback.PerformCallback('Save');
    }

    function onEdit() {
      EnableEdit(true);
    }

    function checkInput(type) {
      var error = '';
      if (type == 'PASS') {
        if (txtOldPass.GetText() == '')
          error = error + '<BR> + <%= GetGlobalResourceObject("Strings", "OldPassword") %>';
        if (txtNewPass.GetText() == '')
          error = error + '<BR> + <%= GetGlobalResourceObject("Strings", "NewPassword") %>';
        if (txtConfirmPass.GetText() == '')
          error = error + '<BR> + <%= GetGlobalResourceObject("Strings", "ConfirmPassword") %>';

      }
      else if (type == 'INFO') {
        if (txtFullName.GetText() == '')
          error = error + '<BR> + <%=GetGlobalResourceObject("Strings", "FullName") %>';
        if (error == '' && txtEmail.GetText() != '' && !ValidateEmail(txtEmail.GetText())) {
          error = '<%=GetGlobalResourceObject("Messages", "ERR0029") %>';
          alertMessage(error);
          return false;
        }
      }
      if (error != '') {
        error = '<%= GetGlobalResourceObject("Messages", "ERR0008") %>' + ' :' + error
        if (type == 'PASS')
          lblErrorMsg.SetText(error);
        else if (type == 'INFO')
          alertMessage(error);
        return false;
      }
      return true;
    }

    function onClear() {
      txtOldPass.SetText('');
      txtNewPass.SetText('');
      txtConfirmPass.SetText('');
      lblErrorMsg.SetText('');
    }

    function onCallbackCompleted(s, e) {
      if (e.parameter.indexOf('ChangePassword') >= 0) {
        if (e.result != '') {
          lblErrorMsg.SetText(e.result);
        }
        else {
          alertMessage('<%=GetGlobalResourceObject("Messages", "ERR0011") %>');
          pupAddEditDlg.Hide();
        }
      }
      else if (e.parameter.indexOf('Save') >= 0) {
        if (e.result != '')
          alertMessage(e.result);
        else
          alertMessage('<%=GetGlobalResourceObject("Messages","ERR0005") %>');
        EnableEdit(false);
      }
    }

    function onChangePassword() {
      onClear();
      pupAddEditDlg.Show();
    }

    function EnableEdit(enable) {
      txtFullName.SetEnabled(enable);
      txtEmail.SetEnabled(enable);
      btnEdit.SetEnabled(!enable);
      btnSave.SetEnabled(enable);
    }
  </script>

</asp:Content>
